(function () {
  var apRetargeting = { key: '', variables: {}, set: function(variable, value) { this.variables[variable] = [':', value]; }, unset: function(variable) { this.variables[variable] = [':', '']; }, inc: function(variable, value) { value = parseInt(value); if (!value) { value = 1; } this.variables[variable] = ['^', value]; }, call: function() { try { var u = 'http:/'+'/ad.adc-serv.net/www/delivery/fc.php?script=apRetargeting:hv-api' + '&key=' + encodeURIComponent(this.key); for (var k in this.variables) { var v = this.variables[k]; u += '&' + v[0] + encodeURIComponent(k) + '=' + encodeURIComponent(v[1]); } u += '&cb=' + Math.floor(Math.random()*99999999999); this.variables = {}; document.createElement('IMG').src = u; } catch (e) { } } };
  var retargeting_value = '';
  var fc = false;
  var loadPixel = function (u) {
  	if(fc){return false;}
    if(retargeting_value.length > 0 && u.indexOf('##VALUE##'))
    {
    	u = u.replace('##VALUE##', retargeting_value);
    }
  	if(u.indexOf('##CACHEBUSTING##'))
  	{
  		u = u.replace('##NO_CACHEBUSTING##', Math.floor(Math.random()*99999999999)); 
  	}
    document.createElement('IMG').src = u;
  }
  var loadHtml = function (u) {
  	if(fc){return false;}
    var i = document.createElement('IFRAME');
    u = u.replace('http://', 'http://');
  	if(u.indexOf('##CACHEBUSTING##'))
  	{
  		u = u.replace('##NO_CACHEBUSTING##', '?' + Math.floor(Math.random()*99999999999)); 
  	}
    i.src = u; i.style.display='none'; document.body.appendChild(i); 
  }
  		
  var isFcSet = function(cookieName) {
	var cookie = getCookie(cookieName);
	if (cookie) {
		return true;
	} else {
		setCookie(cookieName, true, 1);
		return false;
	}
  };

  var getCookie = function(c_name) {
    if (document.cookie.length>0) {
      c_start=document.cookie.indexOf(c_name + "=");
      if (c_start!=-1) {
        c_start=c_start + c_name.length+1;
	c_end=document.cookie.indexOf(";",c_start);
	if (c_end==-1) c_end=document.cookie.length;
	return unescape(document.cookie.substring(c_start,c_end));
      }
    }
    return "";
  };
  var setCookie = function (c_name,value,expiredays) {
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
  };
    
    apRetargeting.key = 'zaMCTcS9EVyj';
    var cut_retvar_char = '';
    var scripts = document.getElementsByTagName('script');
    var script_regexp = /^https?:\/\/r\.adc-serv\.net\/r\/lemomcurve_fr\.js(?:\?(.*))/;
    var iframe_regexp = /^https?:\/\/r\.adc-serv\.net\/r\/lemomcurve_fr\.html(?:\?(.*))/;
    var pairs = new Array();
    
    if( iframe_regexp.test(document.location) ){
        var all = RegExp['$1'].split('&'); 
        for(var i=0;i<all.length;i++){
            if (all[i]){
                pairs.push(all[i]);
            }
        };
    }
    for(var i=0;i < scripts.length;i++) {
        if(scripts[i]['src'] && script_regexp.test(scripts[i]['src'])) {
            var all = RegExp['$1'].split('&');
            for(var j=0;j<all.length;j++){
                if (all[j]){
                    pairs.push(all[j]);
                }
            }
        }
    }
    for(var j=0;j < pairs.length;j++) {
      var val = pairs[j].split('=');
      val[0] = val[0].replace(/[^a-zA-Z0-9_:]/, '_');
      if(val[0].indexOf(':', 0) == 0 && val[1].length) {
        val[0] = val[0].substring(1);
        var c = getCookie(val[0]);
        var c_vs = c.length ? c.split(/[,|]/) : [];
        var vi=0;
        while(vi < c_vs.length && c_vs[vi] != val[1]) vi++;
        if(vi == c_vs.length) c_vs.push(val[1]);
        c_vs = c_vs.slice(-5);
        val[1] = c_vs.join('|');
        setCookie(val[0],val[1],365);
      }
      if(cut_retvar_char.length > 0 && val[1].indexOf(cut_retvar_char)) {
        val[1] = val[1].substring(0, val[1].indexOf(cut_retvar_char));
      }
      apRetargeting.set(val[0], val[1]);
          if(val[1]){
	  if(val[1].length > 0 && retargeting_value.length == 0) {
		retargeting_value = val[1];
          }
	  }
    }

   apRetargeting.call();
   
    loadHtml('http://r.adc-serv.net/r/946931363363983.html');
    loadHtml('http://r.adc-serv.net/r/947921370883063.html');
    loadHtml('http://r.adc-serv.net/r/466351370883063.html');
    loadHtml('http://r.adc-serv.net/r/982001370883063.html');
    loadHtml('http://r.adc-serv.net/r/981821370883063.html');
    loadHtml('http://r.adc-serv.net/r/942141370883063.html');
    loadHtml('http://r.adc-serv.net/r/380751373875743.html');
    loadHtml('http://r.adc-serv.net/r/554421374843141.html');

})();